package com.ruoyi.info.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.info.domain.FhInfoFishpoint;
import com.ruoyi.info.service.IFhInfoFishpointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 钓鱼点管理Controller
 * 
 * @author ruoyi
 * @date 2024-11-27
 */
@RestController
@RequestMapping("/info/fishpoint")
public class FhInfoFishpointController extends BaseController
{
    @Autowired
    private IFhInfoFishpointService fhInfoFishpointService;

    /**
     * 查询钓鱼点管理列表
     */
    @PreAuthorize("@ss.hasPermi('info:fishpoint:list')")
    @GetMapping("/list")
    public TableDataInfo list(FhInfoFishpoint fhInfoFishpoint)
    {
        startPage();
        List<FhInfoFishpoint> list = fhInfoFishpointService.selectFhInfoFishpointList(fhInfoFishpoint);
        return getDataTable(list);
    }

    /**
     * 导出钓鱼点管理列表
     */
    @PreAuthorize("@ss.hasPermi('info:fishpoint:export')")
    @Log(title = "钓鱼点管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FhInfoFishpoint fhInfoFishpoint) throws IOException {
        List<FhInfoFishpoint> list = fhInfoFishpointService.selectFhInfoFishpointList(fhInfoFishpoint);
        ExcelUtil<FhInfoFishpoint> util = new ExcelUtil<FhInfoFishpoint>(FhInfoFishpoint.class);
        util.exportExcel(response, list, "钓鱼点管理数据");
    }

    /**
     * 获取钓鱼点管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('info:fishpoint:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fhInfoFishpointService.selectFhInfoFishpointById(id));
    }

    /**
     * 新增钓鱼点管理
     */
    @PreAuthorize("@ss.hasPermi('info:fishpoint:add')")
    @Log(title = "钓鱼点管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FhInfoFishpoint fhInfoFishpoint)
    {
        return toAjax(fhInfoFishpointService.insertFhInfoFishpoint(fhInfoFishpoint));
    }

    /**
     * 修改钓鱼点管理
     */
    @PreAuthorize("@ss.hasPermi('info:fishpoint:edit')")
    @Log(title = "钓鱼点管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FhInfoFishpoint fhInfoFishpoint)
    {
        return toAjax(fhInfoFishpointService.updateFhInfoFishpoint(fhInfoFishpoint));
    }

    /**
     * 删除钓鱼点管理
     */
    @PreAuthorize("@ss.hasPermi('info:fishpoint:remove')")
    @Log(title = "钓鱼点管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fhInfoFishpointService.deleteFhInfoFishpointByIds(ids));
    }
}
